<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!Doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>登陆</title>
    <link href="/static/css/common/style.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/common/user.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/jquery.js" type="text/javascript"></script>
    <link href="/static/css/common/common.css" rel="stylesheet" type="text/css"/>
    <link href="/static/images/ico/favicon.png" rel="shortcut icon">
    <%--<script src="/static/js/formValidator-4.1.1.js" type="text/javascript"></script>--%>
    <%--<script src="/static/js/formValidatorRegex.js" type="text/javascript"></script>--%>
    <script src="/static/js/common.js" type="text/javascript"></script>

    <%--<script src="/static/js/formcheck.js" type="text/javascript"></script>--%>
    <%--<script src="/static/js/json.min.js" type="text/javascript"></script>--%>
    <%--<script src="/static/js/jquery.json-2.2.min.js" type="text/javascript"></script>--%>
    <style>
        table, tr, td {
            border: none;
        }

        table tr {
            height: 50px;
        }

        .noticeWrap {
            padding: 0px;
            float: none;
        }

        .noticeWrap span {
            float: none;
            line-height: normal;
        }

        .user_client p {
            margin-bottom: 0px;
            width: 100%;
            float: none;
        }
    </style>
</head>
<body id="reg">
<%--<jsp:include page="themes/header.jsp"/>--%>
<div class="w100">
    <div class="w1000" style="height: 480px">
        <div class="login_pic">
            <h1>用户登录</h1>
        </div>
        <div class="user_client">
            <div class="user_client_left">
                <form id="regform" method="post" action="#" onsubmit="return false;">
                    <table class="tab1">
                        <tr>
                            <td align="right">* 账号</td>
                            <td><input type="text" id="username" name="username" placeholder="账号"/></td>
                            <td>
                                <div id="tnameTip" style="width:280px"></div>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">* 密码填写:</td>
                            <td><input type="password" id="pwd" name="pwd" placeholder="密码"/></td>
                            <td>
                                <div id="passwordTip" style="width:280px"></div>
                            </td>
                        </tr>
                    </table>
                    <p>
                        <span> <input type="submit" value="用户登陆" class="uc_submit btn_yellow"
                                      onclick="login();"> </span>
                        <%--<span class="quicklogin">没有账号? <a class="fcf60" href="/loginReg/reg.do">点此注册 »</a></span>--%>
                    </p>
                </form>
            </div>
            <div class="clearer"></div>
        </div>
    </div>
    <jsp:include page="themes/footer.jsp"/>
</div>
</body>
<script type="text/javascript">
    function login() {
        var name = $("#username").val();
        var pwd = $("#pwd").val();
        if (name == "") {
            alert("亲爱的用户，请输入帐号！");
            return;
        }
        if (pwd == "") {
            alert("亲爱的用户，请输入密码！");
            return;
        }
        loginSubmit(name,pwd);
    }
    document.onkeydown = function(event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            var name = $("#userName").val();
            var pwd = $("#pwd").val();
            if (name == "") {
                alert("亲爱的用户，请输入帐号！");
                return;
            }
            if (pwd == "") {
                alert("亲爱的用户，请输入密码！");
                return;
            }
            loginSubmit(name,pwd);
        }
    }
    function loginSubmit(name,pwd){
        $.ajax({
            type: "POST",
            url: '/loginCheck.do',
            data: {"username":name,"pwd":pwd},
            success: function(ret){
                if(ret.msg=='1'){
                    alert("恭喜你登陆成功");
                    window.location.href="/index.do";
                } else {
                    alert("账号或者密码错误！");
                }
            }
        });
    }
</script>
</html>
